package com.uobgroup.ews.uam.core.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.beans.factory.annotation.Configurable;

@Entity
@Configurable
public class UAMUser extends BaseEntity {

   @NotNull
   @Column(unique = true)
   @Size(max = 32)
   private String username;

   @NotNull
   private String proxyUser;

   @NotNull
   @Column(name = "IsActive", nullable = false, columnDefinition = "boolean default false")
   private Boolean isActive;

   @OneToOne
   private Profile profile;

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id")
   private Long id;

   private Integer status;

   /**
    * @return the status
    */
   public Integer getStatus() {
      return status;
   }

   /**
    * @param status
    *           the status to set
    */
   public void setStatus(Integer status) {
      this.status = status;
   }

   @Column(name = "IsLocked", nullable = false, columnDefinition = "boolean default false")
   private Boolean IsLocked;

   /**
    * @return the isLocked
    */
   public Boolean getIsLocked() {
      return IsLocked;
   }

   /**
    * @param isLocked
    *           the isLocked to set
    */
   public void setIsLocked(Boolean isLocked) {
      IsLocked = isLocked;
   }

   /**
    * @return the isDeleted
    */
   public Boolean getIsDeleted() {
      return IsDeleted;
   }

   /**
    * @param isDeleted
    *           the isDeleted to set
    */
   public void setIsDeleted(Boolean isDeleted) {
      IsDeleted = isDeleted;
   }

   @Column(name = "IsDeleted", nullable = false, columnDefinition = "boolean default false")
   private Boolean IsDeleted;

   @Column(name = "IsAdmin", nullable = false, columnDefinition = "boolean default false")
   private Boolean IsAdmin;

   /**
    * @return the isAdmin
    */
   public Boolean getIsAdmin() {
      return IsAdmin;
   }

   /**
    * @param isAdmin
    *           the isAdmin to set
    */
   public void setIsAdmin(Boolean isAdmin) {
      IsAdmin = isAdmin;
   }
   
   @OneToOne
   private ApplicationConfiguration domain;
   
   @NotNull
   @OneToOne
   private Reference country;

   public Reference getCountry() {
	return country;
}

public void setCountry(Reference country) {
	this.country = country;
}

/**
    * @return the domain
    */
   public ApplicationConfiguration getDomain() {
      return domain;
   }

   /**
    * @param domain
    *           the domain to set
    */
   public void setDomain(ApplicationConfiguration domain) {
      this.domain = domain;
   }

   public Long getId() {
      return this.id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public String toString() {
      return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
   }

   public String getUsername() {
      return this.username;
   }

   public void setUsername(String username) {
      this.username = username;
   }

   public String getProxyUser() {
      return this.proxyUser;
   }

   public void setProxyUser(String proxyUser) {
      this.proxyUser = proxyUser;
   }

   public Boolean getIsActive() {
      return this.isActive;
   }

   public void setIsActive(Boolean isActive) {
      this.isActive = isActive;
   }

   public Profile getProfile() {
      return profile;
   }

   public void setProfile(Profile profile) {
      this.profile = profile;
   }

   private Integer attemptNum;
      
   public Integer getAttemptNum() {
      return attemptNum;
   }
   
   public void setAttemptNum(Integer attemptNum) {
      this.attemptNum = attemptNum;
   }

   private Date lastLogonDate;
   
   public Date getLastLogonDate() {
      return lastLogonDate;
   }

   public void setLastLogonDate(Date lastLogonDate) {
      this.lastLogonDate = lastLogonDate;
   }
   
   @Transient
   private String searchUsername;

   
   public String getSearchUsername() {
      return searchUsername;
   }

   
   public void setSearchUsername(String searchUsername) {
      this.searchUsername = searchUsername;
   }

}
